// pages/information/information.js
import { messageSystem} from '../../api.js'
let app=getApp();
Page({
  data: {
    isUser:true,
    informationList:[ //消息列表
      // {id:1,title:'系统2.0版本更新'},
      // {id:2,title:'系统1.8版本更新'}
      ],
    page:1,
    last_page:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    messageSystem({token:app.globalData.token}).then(res=>{
      console.log('res',res)
      if(res.data.code==666){
        let data = res.data.data
        this.setData({
          informationList: data.data,
          page: data.current_page,
          last_page: data.last_page
        })
      } else if (res.data.code == 111111) {
        wx.showToast({
          title: '登录失效，请重新登录',
          icon: 'none',
        })
        setTimeout(function () {
          wx.reLaunch({
            url: '/pages/user/login/login',
          })
        }, 1500)
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: 'none'
        })
      }
    })
  },
  changeInfo(e){
    console.log(e)
      this.setData({
        isUser: (e.currentTarget.dataset.info == 1)?true:false
      })      
  },
  skipItem(e){
    console.log(e)
    wx.navigateTo({
      url: '/pages/information/informationDetail/informationDetail?title=' + e.currentTarget.dataset.title + '&content=' + e.currentTarget.dataset.content,
    })
  },
})